home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / hypercrd / xcmds / shwdlg16.hqx / ShowDialog XCMD 1.6 / card_13104.txt < prev    next >
Text File  |  1989-05-10  |  12KB  |  322 lines

  1. -- card: 13104 from stack: in.6
  2. -- bmap block id: 5804
  3. -- flags: 2000
  4. -- background id: 3411
  5. -- name: Type 7 XCMD
  6. ----- HyperTalk script -----
  7. on closeCard
  8.   lock screen
  9.   hide cd pict
  10.   hide cd btn "OK"
  11.   unlock screen
  12.   pass closeCard
  13. end closeCard
  14.  
  15. on showButtons
  16.   show cd btn ID 1
  17.   show cd btn ID 2
  18. end showButtons
  19.  
  20. on turnOn
  21.   hide cd pict
  22.   pass turnOn
  23. end turnOn
  24.  
  25.  
  26. -- part 1 (button)
  27. -- low flags: 80
  28. -- high flags: A003
  29. -- rect: left=291 top=120 right=142 bottom=413
  30. -- title width / last selected line: 0
  31. -- icon id / first selected line: 0 / 0
  32. -- text alignment: 1
  33. -- font id: 0
  34. -- text size: 12
  35. -- style flags: 0
  36. -- line height: 16
  37. -- part name: Many Selections
  38. ----- HyperTalk script -----
  39. on mouseUp
  40.   put "          Help Topics" into prompt
  41.   ShowDialog 7,5002,prompt,geneva,9,cd fld "Test",5,"many"
  42.   if line 1 of the result = 2 then
  43.     put "You clicked the ΓÇ£CancelΓÇ¥ button." into bg fld "theResult"
  44.   else
  45.     if the number of items in line 2 of the result = 1 then
  46.       put "You clicked on line" && line 2 of the result & "." into bg fld "theResult"
  47.     else put "Hilited lines:" && line 2 of the result into bg fld "theResult"
  48.   end if
  49. end mouseUp
  50.  
  51.  
  52.  
  53. -- part 2 (button)
  54. -- low flags: 80
  55. -- high flags: A003
  56. -- rect: left=291 top=165 right=187 bottom=413
  57. -- title width / last selected line: 0
  58. -- icon id / first selected line: 0 / 0
  59. -- text alignment: 1
  60. -- font id: 0
  61. -- text size: 12
  62. -- style flags: 0
  63. -- line height: 16
  64. -- part name: One Selection
  65. ----- HyperTalk script -----
  66. on mouseUp
  67.   put empty into bg fld "theResult"
  68.   put "aramadillo" & return & "cockroach" & return & "doodoo" & return & "duck" & return & "flamingo" & return & "kangaroo" & return & "lobster" & return & "moose" & return & "penguin" & return & "shark" & return & "walrus" & return & "wart hog" & return into container
  69.   put "                    Animals" into prompt
  70.   put 1 into theItem
  71.   repeat
  72.     ShowDialog 7,5004,prompt,chicago,12,container,theItem,"one"
  73.     put the result into theResult
  74.     put line 2 of theResult into theItem
  75.     if line 1 of theResult = 5 then
  76.       ShowDialog 1,5000,"",FALSE
  77.       exit repeat
  78.     end if
  79.     if line 1 of theResult = 2 then exit repeat
  80.     ShowDialog 6,5003,3001,12,line 2 of theResult,FALSE
  81.     put the result into theResult
  82.  
  83.     --ΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇó  Notes on Type 6 of ShowDialog  ΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇó
  84.     -- If the user clicked the TOPICS button (DITL item #7) the
  85.     -- result will be TRUE.
  86.     -- If the user clicked the CANCEL button (DITL item #1) the
  87.     -- result will be FALSE.
  88.     -- Use the TRUE/FALSE values to respond to the dialog (as in
  89.     -- this example).
  90.  
  91.  
  92.     if theResult is FALSE then exit repeat
  93.   end repeat
  94. end mouseUp
  95.  
  96.  
  97.  
  98. -- part 3 (field)
  99. -- low flags: 80
  100. -- high flags: 2007
  101. -- rect: left=164 top=19 right=278 bottom=481
  102. -- title width / last selected line: 0
  103. -- icon id / first selected line: 0 / 0
  104. -- text alignment: 0
  105. -- font id: 3
  106. -- text size: 10
  107. -- style flags: 0
  108. -- line height: 13
  109. -- part name: test
  110.  
  111.  
  112. -- part 4 (button)
  113. -- low flags: 80
  114. -- high flags: A003
  115. -- rect: left=405 top=266 right=288 bottom=440
  116. -- title width / last selected line: 0
  117. -- icon id / first selected line: 0 / 0
  118. -- text alignment: 1
  119. -- font id: 0
  120. -- text size: 12
  121. -- style flags: 0
  122. -- line height: 16
  123. -- part name: OK
  124. ----- HyperTalk script -----
  125. on mouseUp
  126.   lock screen
  127.   hide me
  128.   hide cd pict
  129.   unlock screen with zoom in
  130. end mouseUp
  131.  
  132.  
  133.  
  134. -- part 7 (button)
  135. -- low flags: 00
  136. -- high flags: 0000
  137. -- rect: left=11 top=4 right=64 bottom=78
  138. -- title width / last selected line: 0
  139. -- icon id / first selected line: 529 / 529
  140. -- text alignment: 1
  141. -- font id: 0
  142. -- text size: 12
  143. -- style flags: 0
  144. -- line height: 16
  145. -- part name: SD
  146.  
  147.  
  148. -- part contents for background part 21
  149. ----- text -----
  150. ShowDialog XCMD Type 7
  151.  
  152. -- part contents for background part 30
  153. ----- text -----
  154. 19
  155.  
  156. -- part contents for background part 15
  157. ----- text -----
  158. ShowDialog Type 7 parameters are:
  159.  
  160. ShowDialog 7,<DLOG resource ID>,<prompt string>,
  161. <font>,<font size>,<list contents>,
  162. <line number hilited>,<single select>,[<top coord>,
  163. <left coord>]
  164.  
  165. where
  166. 7 is the type;
  167. <DLOG resource ID> is the ID of the DLOG resource;
  168. <prompt string> is a string of text that can appear in the dialog;
  169. <font> is the font that the scrolling list will appear in;
  170. <font size> is the font size that the scrolling list will appear in;
  171. <list contents> is a return delimited variable or field that will make up the scrolling list;
  172. <line number hilited> is the line of the scrolling list that will be hilited when the dialog is shown.
  173. Pass "0" (that's a zero) if you want NO line initially hilited;
  174. <single select> configures the scrolling list so that only one line can be selected at at time.  If this parameter is "one" then only one line can be selected.  If it is "many" then Shift-clicking will select multiple lines and Shift-click-dragging will select 
  175. "continuous" lines.  This parameter must be in quotes in the parameter list.
  176.  
  177. The last two parameters are OPTIONAL.  They set the top, left coordinates of the dialog.  If these two parameters are omitted the dialog will be centered within the card window.
  178.  
  179.  
  180.  
  181. -- part contents for background part 17
  182. ----- text -----
  183. ΓÇó Prompt String Font
  184. The <prompt string> will always appear in Chicago 12 pt.
  185.  
  186.  
  187. ΓÇó Scrolling List Font
  188. If the font that you specify for the list isn't available, Chicago will be substituted.
  189. If (for some reason) you specify 0 as the point size, 12 pt will be substituted.
  190.  
  191.  
  192. ΓÇó Regular Buttons
  193. ShowDialog Type 7 can have as many "regular" buttons as you want.  ShowDialog will return the DITL item# of the button clicked as line 1 of the Result.  If enter or return is typed, or the user double-clicks on a line in the scrolling field, line 1 of the result will contain the DITL item# of the default button (which is ALWAYS 1).  If the user types command-period, line 1 of the result will ALWAYS contain DITL item# 2.
  194.  
  195.  
  196. ΓÇó Static Text
  197. The Dialog Manager allows you to have ONLY ONE font in a dialog.  Any static text that you put in your DLOG template will appear in the same font (and size) as the list (I got around this restriction with the prompt string by hard coding its font attributes).  So if you wish to have static text in your dialog that is NOT in the same font as the list, make this text in a "paint" program and add it to the DLOG template as a PICT.
  198.  
  199.  
  200. ΓÇó The DLOG/DITL Template
  201. In designing your DLOG/DITL template there are some things to keep in mind:
  202.  
  203. DITL item #1 is the OK button.
  204. DITL item #2 is the CANCEL button.
  205. DITL item #3 is the scrolling list.  This must be a ENABLED useritem.
  206. DITL item #4 is the prompt string.  This MUST be a DISABLED useritem.  If you don't want a prompt string, DITL item #4 can be anything else (Just pass "" in the <prompt string> parameter.)
  207.  
  208. DITL items #5 ... onward can be regular buttons, icons, PICTs, and static text.
  209.  
  210.  
  211. ΓÇó The Scrolling List DITL  Item
  212. In constructing the useritem that will be the scrolling list:
  213. The list will have a vertical scroll bar which will lie OUTSIDE the useritem and will be 15 pixels wide.  So leave a 15 pixel-wide space TO THE RIGHT of useritem DITL #3 for the scroll bar (otherwise the scroll bar could overlap with something else you have placed in the DLOG template).   ΓÇó Click┬áhere┬áto┬ásee. ΓÇó
  214.  
  215. Just prior to displaying the dialog, ShowDialog calculates the line height of the list based on the ascent + decent + leading of the font that you have specified.
  216.  
  217. In order for the list to be displayed correctly, the vertical height of useritem DITL #3 must be an EXACT MULTIPLE of the line height of the list.
  218.  
  219. You don't have to worry about this yourself.  ShowDialog takes a look at the dimensions of the useritem, and, if the vertical height is not EXACTLY a multiple of the line height, IT ADJUSTS THE VERTICAL HEIGHT OF THE USERITEM FOR YOU.
  220.  
  221. So, if you find that the rect of DISPLAYED list is slightly different from the one that you specified in your DLOG template, it is because the useritem was a little off in its dimensions.  In other words, when you design your DLOG template, put the useritem approximately where you want it and ShowDialog will position it correctly.
  222.  
  223. The reason for all this is purely aesthetic.  
  224. ΓÇó Show┬áme. ΓÇó
  225.  
  226. The result is a RETURN-delimited list:  
  227. Line 1:  DITL item# of button clicked.
  228. Line 2: comma-delimited list of lines from the scrolling list that were hilited: 
  229. first hilited line, second hilited line, third hilited line, etc.
  230.  
  231. If the user hits enter or return, or double-clicks on a line in the scrolling list, line 1 of the result will contain the DITL item# of the default button (which is ALWAYS 1).  This is why DITL item# 1 should be OK.
  232.  
  233. If the user types command-period, line 1 of the result will contain 2 (DITL item# 2).  This is why DITL item# 2 should ALWAYS be CANCEL.
  234.  
  235. The other "buttons" can be hot spots, if you like.  Just put ENABLED useritems in your DLOG template.  If you're going to associate these hot spots with a graphic in the dialog, remember that the hot spot useritems must lie "UNDER" the graphic PICT.
  236. See "All PICT Dialogs" under "Special Notes" on the Special Dialogs Card for details on how to do this.
  237. ΓÇó Click┬áhere┬áand┬ágo┬áthere┬ánow. ΓÇó
  238.  
  239.  
  240.  
  241. -- part contents for card part 3
  242. ----- text -----
  243. About ShowDialog
  244. Alert Types
  245. cicn's
  246. Color Icon Bars
  247. Debugging ShowDialog
  248. Dialog Types
  249. Making PICT's
  250. Obtaining ResEdit
  251. Other X-Commands:
  252. ┬á┬á┬á┬áAnts XFCN
  253. ┬á┬á┬á┬áClipToPICT XCMD
  254. ┬á┬á┬á┬áColorOn XFCN
  255. ┬á┬á┬á┬áPrintDocs XCMD
  256. PICT Maker
  257. Registration
  258. ResEdit
  259. Shareware
  260. ShowDialog Types:
  261. ┬á┬á┬á┬áType 1
  262. ┬á┬á┬á┬áType 2
  263. ┬á┬á┬á┬áType 3
  264. ┬á┬á┬á┬áType 4
  265. ┬á┬á┬á┬áType 5
  266. ┬á┬á┬á┬áType 6
  267. ┬á┬á┬á┬áType 7
  268. Special Dialogs
  269. Splash Screens
  270. Window Types
  271.  
  272.  
  273. -- part contents for background part 18
  274. ----- text -----
  275.            •••••••••••••••••
  276. If you've been using versions of ShowDialog older than 1.6, please note that the PARAMETERS AND RESULT for Type 7 have changed to increase its functionality.  
  277.  
  278. You can now configure the scrolling list so that only one line can be selected at a time.  
  279.  
  280. The result is now RETURN-delimited.  Line 1 of the result is the DITL item# of the button clicked.  Line 2 of the result is a comma-delimited list of the lines from the scrolling list that were hilited.
  281.            •••••••••••••••••
  282.  
  283. ShowDialog Type 7 displays a dialog that contains a scrolling list.  Use this type of dialog in situations where the user must select from a list of items.
  284.  
  285. Type 7 can contain icons, PICTs, static text, and any number of "regular" buttons in addition to the scrolling list.
  286.  
  287.  
  288. ΓÇóFunction of the Scrolling List
  289.  
  290. The scrolling list can be configured so that only one line can be selected at a time, or can be configured so that Shift-clicking will select multiple lines and Shift-click-dragging will select "continuous" lines.
  291.  
  292. Dragging the mouse above or below the list will scroll it in that direction.
  293.  
  294. Double clicking on a line or hitting return or enter is the same as clicking the OK button.
  295.  
  296. Typing command-period is the same as clicking the CANCEL button.
  297.  
  298. The scrolling list is subject to full keyboard control and will respond to "hot keys":
  299.  
  300.    ΓÇó To scroll the list up:
  301.          press the cursor up button
  302.          press the page up button
  303.          press the "less than" (<) button (no need to shift)
  304.  
  305.   ΓÇó To scroll the list down:
  306.          press the cursor down button
  307.          press the page down button
  308.          press the "greater than" button (no need to shift)
  309.  
  310.   ΓÇó To scroll list to the top:
  311.          press the home button
  312.  
  313.   ΓÇó To scroll list to the end:
  314.          press the end button
  315.  
  316.   ΓÇó To directly to a line ("hot keys"):
  317.          The list will scroll to a line that begins with the     ┬á┬á┬á┬áletter that you type.  This function is only useful, ┬á┬á┬á┬áof course, if you alphabetize your list items.
  318.  
  319. There is no limit to the number of lines that a list can contain.  The more lines in the list, the longer it will take before the dialog is displayed.  ShowDialog displays the watch cursor while it constructs the list 
  320. (although this time is negligible for lists of any reasonable length).
  321.  
  322.